<!-- 今日加速用户排名 -->
<template>
  <div class="wrap">
    <span  class="title">top <span>10</span> 今日加速用户排名</span>
    <piechart :title="'访问用户统计分析'"  id="chart3" :chartData="pieData" />
    <!-- <el-table stripe border :data="dataList" style="width: 100%; margin: 15px 0">
      <el-table-column label="序号" width="50" align="center" type="index"></el-table-column>
      <el-table-column label="ip" align="center" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.Name }}
        </template>
      </el-table-column>
      <el-table-column label="加速次数" width="100" align="center">
        <template slot-scope="scope">
          {{ scope.row.Count }}
        </template>
      </el-table-column>
    </el-table> -->
  </div>
</template>
<script>
import piechart from "./piechart.vue";
import { connrequest } from "@/api/firstPage";
import { getNowDay } from '@/utils/index.js' 
export default {
  components:{piechart},
  data() {
    return {
      dataList: [],
      pieData:[]
    };
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.getData();
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
  methods: {
    async getData() {
      let arr = []
      let NowDay = getNowDay('time')
      const data = {
        Filter: {
          StartTime: NowDay,
          EndTime: "",
          AccessType: 2,
          SumCount: 9
        }
      }
      const res = await connrequest('GetShadowURLSumGroupByUser', data);
      if(res.Data){
        res.Data.map(item => {
          // item.Count = item.Count.toLocaleString()
          arr.push({name: item.Name, value: item.Count})
        })
        this.pieData = arr
        this.dataList = res.Data;
      }else{
        const dom = document.getElementById('chart3');
        dom.innerHTML = '<div class="el-table__empty-block"><span class="el-table__empty-text">暂无数据</span></div>';
        dom.removeAttribute('_echarts_instance_');
      }
    }
  }
};
</script>
<style scoped lang='scss'>
.wrap {
  height: 370px;
  overflow: hidden;
}
</style>